<template>
	<view class="bodys">
		<view class="title">{{obj.tit}}</view>
		<view class="num" @click="add_click">{{obj.num}}</view>
		<text>
			点击提交将数据提交到数据库
		</text>
		<button @click.native="sub">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

				obj: {
					_id:'',
					tit: '',
					num: 0,
					user_id:''
				},
				id:"",
				indexs: 0
			}
		},
		onLoad: function(option) {
			console.log(option.id);
			this.get_list(option.id)
			this.obj._id=option.id
			this.id=option.id
		},
		methods: {
			sub(){
				const db = uniCloud.database()
				
				delete this.obj._id
				console.log(this.id)
				db.collection('jishuqi_list').doc(this.id).update(this.obj).then(res => {
					console.log(res)
					uni.showToast({
						title:'提交成功',
						icon:'none'
					})
				})
			},
			add_click() {
				this.obj.num = this.obj.num += 1
				uni.setStorageSync('LIST_INDEX',this.obj)
			},
			get_list(id) {
				const db = uniCloud.database()
				db.collection('jishuqi_list').where({
					_id: id
				}).get().then(res => {
					this.obj = res.result.data[0]
					console.log(res)
				})


			}
		}
	}
</script>

<style scoped>
	.bodys {
		width: 100vw;
		height: calc(100vh - 100rpx);
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		text-align: center;
	}

	.title {
		width: 100%;
		height: 20%;
		display: block;
		color: #fff;
		font-size: 66rpx;
		font-weight: bold;
		display: flex;
		justify-content: center;
		align-items: center;
		background: #bc601a;
	}

	.num {
		width: 100%;
		height: 80%;
		display: block;
		color: #fff;
		font-size: 100rpx;
		font-weight: bold;
		display: flex;
		justify-content: center;
		align-items: center;
		background: #df7320;

	}
	
	text{
		margin-top: 10rpx;
		color: #df7320;
		font-size:32rpx; 
	}
	
	button{
		width: 90%;
		height:80rpx;
		line-height:80rpx;
		color: #fff;
		font-size: 36rpx;
		background: #3b6cd5;
		margin-top: 20rpx;
	}
</style>